package com.zhiyou100.extendsDemo2;

/**
 * 汽车类
 * final: 修饰方法是，表示这个方式是最终方法，只能用，不能被重写
 *      修饰属性，表示这个属性不能被修改(常量)，我们一般可以通过构造方法对其进行初始化
 */
public class Vehicle {
    final String brand; //汽车品牌
    String color; //颜色
    double speed; //速度

    public String getBrand() {
        return brand;
    }

    public String getColor() {
        return color;
    }

    public void setColor(String color) {
        this.color = color;
    }

    public double getSpeed() {
        return speed;
    }

    public void setSpeed(double speed) {
        this.speed = speed;
    }

    public Vehicle(String brand){
        this.brand = brand;
        this.speed = 0.0;
    }

    public Vehicle(String brand,String color){
        this(brand);
        this.color = color;
    }

    public void run() {
        System.out.println("颜色为" + color + "的" + brand + "汽车在行驶");
    }


    public static void main(String[] args) {

        Vehicle vehicle = new Vehicle("奥迪");
        System.out.println(vehicle.brand);
        vehicle.color = "red";
        vehicle.speed = 300;

    }

}
